package com.marktotop.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.marktotop.entity.business.ReservationRecord;
import com.marktotop.vo.business.ReservationRecordVO;
import com.marktotop.vo.business.SiteReservationVO;
import com.marktotop.vo.business.VaccineInSiteVO;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author MarkToTop
 * @since 2021-07-12
 */
public interface ReservationRecordMapper extends BaseMapper<ReservationRecord> {


    /**
     * 分页展示所有预约记录列表，并进行模糊查询
     *
     * @param page
     * @param reservationRecordVO
     * @return
     */
    IPage<ReservationRecordVO> getReservationRecordByPage(Page<ReservationRecordVO> page, @Param("record") ReservationRecordVO reservationRecordVO);


    /**
     * 查询某个接种点下，某个疫苗信息
     *
     * @param siteId
     * @param vaccId
     * @return
     */
    VaccineInSiteVO getVaccAndSite(@Param("siteId") Long siteId, @Param("vaccId")Long vaccId);


    /**
     * 更新 中间表库存也就是修改该接种点下的疫苗库存
     *
     * @param newCount
     * @param siteId
     * @param vaccineId
     * @return
     */
    int updateCount(@Param("newCount") int newCount, @Param("siteId") Long siteId, @Param("vaccineId") Long vaccineId);


    /**
     * 获取单个预约信息
     *
     * @param id
     * @return
     */
    ReservationRecordVO getOneReservationRecord(@Param("id") Long id);


    /**
     * 根据预约id找到疫苗id和接种点id
     *
     * @param id
     * @return
     */
    ReservationRecord findSiteAndVaccByRId(Long id);


    /**
     * 根据接种点id和疫苗id获取当前库存
     *
     * @param vaccSiteId
     * @param vaccineId
     * @return
     */
    Integer findStockInfoBySidAndVid(@Param("siteId") Long vaccSiteId,@Param("vaccineId") Long vaccineId);


    /**
     * 根据接种点id查找该接种点所有的疫苗预约信息
     *
     * @param id
     * @return
     */
    SiteReservationVO getReservationRecordsBySite(Long id);

}
